package com.team5101.util;

import java.io.*;


public class Obj2ByteUtil {

    public static long byteArrayToLong(byte[] data) throws IOException {
        ByteArrayInputStream bai = new ByteArrayInputStream(data);
        DataInputStream dis = new DataInputStream(bai);
        return dis.readLong();
    }

    public static byte[] longToByteArray(Long time) throws IOException {
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bao);
        dos.writeLong(time);
        byte[] buf = bao.toByteArray();
        return buf;
    }
}
